package com.chixing.day04_oop.work;


//信用账户
public class CreditAccount extends Account{
    //最高透支额度
    private Integer maxOverdraw;
    //信用度
    private Integer creditRating;

    public CreditAccount(String accountId, String accountPassword, Integer accountBalance, Integer maxOverdraw, Integer creditRating) {
        super(accountId, accountPassword, accountBalance);
        this.maxOverdraw = maxOverdraw;
        this.creditRating = creditRating;
    }

    public CreditAccount(Integer maxOverdraw, Integer creditRating) {
        this.maxOverdraw = maxOverdraw;
        this.creditRating = creditRating;
    }

    /**
     * 信用账户重写取款的功能，账户余额不够时，可以进行透支（业务简单实现即可）
     * @param money
     */
    @Override
    public void withdraw(int money) {
        if(super.getAccountBalance()-money<0)
            System.out.println("可以进行透支,需要透支金额: "+(super.getAccountBalance()-money));
        else {
            super.setAccountBalance(super.getAccountBalance()-money);
            System.out.println("取款成功,当前余额: "+super.getAccountBalance());
        }
    }


}
